// @ts-ignore
import locale from "pnpm";
import { createI18n } from "vue-i18n"
// @ts-ignore
import lowcode from "@/render/utils/lowcode";
export const I18N_KEY_MAPS = {
  zhCN: "zh_CN",
  enUS: "en_US",
};

// @ts-ignore
const customCreateI18n = ({ locale, messages }) => {
  const newMessages = {};
  Object.keys(messages).forEach((key) => {
    // @ts-ignore
    const lang = I18N_KEY_MAPS[key] || key;
    // @ts-ignore
    newMessages[lang] = messages[key];
  });

  return createI18n({
    locale,
    messages: newMessages,
    legacy: false,
  });
};

const i18n = locale.initI18n({
  i18n: { locale: "zh_CN" },
  createI18n: customCreateI18n,
  messages: {
    zhCN: {
      change_lang: "切换语言",
    },
    enUS: {
      change_lang: "change lang",
    },
  },
});


i18n.lowcode = lowcode;

// export const defineCustomI18n = (customI18n) => {
//   Object.assign(i18n, customI18n)
// }

export default i18n

